﻿using System;
using System.ComponentModel;
using System.Windows.Forms;
using OmegaBot;


namespace drone_cc
{
    public partial class droneRogueSetup : ClassSetupPanel
    {
        droneRogueCombat combatClass = null;

        public droneRogueSetup()
        {
            InitializeComponent();
        }

        public droneRogueSetup(droneRogueCombat combatClass)
            : base()
        {
            // Save a reference to the combat class so you can get to config!
            this.combatClass = combatClass;
            InitializeComponent();

            // Load from config:
            cbx_UseStealth.Checked = combatClass.Ini.GetBoolean("rogue", "usestealth", false);
            cbx_UseOpener.Checked = combatClass.Ini.GetBoolean("rogue", "useopener", false);
            cbx_UseKick.Checked = combatClass.Ini.GetBoolean("rogue", "usekick", false);
            cbx_UseRangedPull.Checked = combatClass.Ini.GetBoolean("rogue", "userangedpull", false);
            cbx_UseSpam.Checked = combatClass.Ini.GetBoolean("rogue", "usespam", false);
            cbx_UseFinisher1.Checked = combatClass.Ini.GetBoolean("rogue", "usefinisher1", false);
            cbx_UseFinisher2.Checked = combatClass.Ini.GetBoolean("rogue", "usefinisher2", false);

            cmb_Opener.Text = combatClass.Ini.GetString("rogue", "opener");
            cmb_Spam.Text = combatClass.Ini.GetString("rogue", "spam");
            cmb_Finisher1.Text = combatClass.Ini.GetString("rogue", "finisher1");
            cmb_Finisher2.Text = combatClass.Ini.GetString("rogue", "finisher2");
            cmb_FinisherAt1.Text = combatClass.Ini.GetString("rogue", "finisher1at");
            cmb_FinisherAt2.Text = combatClass.Ini.GetString("rogue", "finisher2at");

            cbx_MHPoison.Checked = combatClass.Ini.GetBoolean("rogue", "usemhpoison", false);
            cbx_OHPoison.Checked = combatClass.Ini.GetBoolean("rogue", "useohpoison", false);
            cmb_MHPoison.Text = combatClass.Ini.GetString("rogue", "mhpoison");
            cmb_OHPoison.Text = combatClass.Ini.GetString("rogue", "ohpoison");

            cbx_UseMount.Checked = combatClass.Ini.GetBoolean("rogue", "usemount", false);
            cbx_SkipLootCheck.Checked = combatClass.Ini.GetBoolean("paladin", "skiplootcheck", false);
            tbx_MountDistance.Text = combatClass.Ini.GetString("rogue", "mountdistance");

            cbx_CombineElementals.Checked = combatClass.Ini.GetBoolean("rogue", "combineitems", false);
            cbx_OpenClams.Checked = combatClass.Ini.GetBoolean("rogue", "openclams", false);

            cbx_EnablePVP.Checked = combatClass.Ini.GetBoolean("rogue", "enablepvp", false);
        }

        // Throw a FormInvalidException if there's a problem!
        public override void ValidateClassSetup()
        {
            int TestIntParsed;
            if (!Int32.TryParse(tbx_MountDistance.Text, out TestIntParsed))
                throw new FormInvalidException("Please input a valid safe mounting distance.", tbx_MountDistance);
            // Parsed ok but is it correct value?
            if (TestIntParsed < 1)
                throw new FormInvalidException("Please input a valid safe mounting distance.", tbx_MountDistance);
            // Ok all things are good.
        }

        public override void CommitValues()
        {
            // ValidateClassSetup already got called and didn't crash, so everything must be ok!
            combatClass.Ini.Set("rogue", "usestealth", cbx_UseStealth.Checked);
            combatClass.Ini.Set("rogue", "useopener", cbx_UseOpener.Checked);
            combatClass.Ini.Set("rogue", "usekick", cbx_UseKick.Checked);
            combatClass.Ini.Set("rogue", "userangedpull", cbx_UseRangedPull.Checked);
            combatClass.Ini.Set("rogue", "usespam", cbx_UseSpam.Checked);
            combatClass.Ini.Set("rogue", "usefinisher1", cbx_UseFinisher1.Checked);
            combatClass.Ini.Set("rogue", "usefinisher2", cbx_UseFinisher2.Checked);

            combatClass.Ini.Set("rogue", "opener", cmb_Opener.Text);
            combatClass.Ini.Set("rogue", "spam", cmb_Spam.Text);
            combatClass.Ini.Set("rogue", "finisher1", cmb_Finisher1.Text);
            combatClass.Ini.Set("rogue", "finisher2", cmb_Finisher2.Text);
            combatClass.Ini.Set("rogue", "finisher1at", cmb_FinisherAt1.Text);
            combatClass.Ini.Set("rogue", "finisher2at", cmb_FinisherAt2.Text);

            combatClass.Ini.Set("rogue", "usemhpoison", cbx_MHPoison.Checked);
            combatClass.Ini.Set("rogue", "useohpoison", cbx_OHPoison.Checked);
            combatClass.Ini.Set("rogue", "mhpoison", cmb_MHPoison.Text);
            combatClass.Ini.Set("rogue", "ohpoison", cmb_OHPoison.Text);

            combatClass.Ini.Set("rogue", "usemount", cbx_UseMount.Checked);
            combatClass.Ini.Set("rogue", "skiplootcheck", cbx_SkipLootCheck.Checked);
            combatClass.Ini.Set("rogue", "mountdistance", tbx_MountDistance.Text);

            combatClass.Ini.Set("rogue", "combineitems", cbx_CombineElementals.Checked);
            combatClass.Ini.Set("rogue", "openclams", cbx_OpenClams.Checked);

            combatClass.Ini.Set("rogue", "enablepvp", cbx_EnablePVP.Checked);

            combatClass.Ini.Save();
        }




    }
}
